package week09;

import java.util.*;
import java.util.Map.Entry;

public class Main2 {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in 

);

Map<String, Integer> map = new HashMap<String, Integer>();

// Set<String> set = new TreeSet<String>();
while (sc.hasNextLine()) {
String str = sc.next();
if (str.equals("!!!!!")) {
break;
} else {

if (map.get(str) == null) {
map.put(str, 1);
} else
map.put(str, map.get(str) + 1);
}
}

List<Map.Entry<String, Integer>> list = new ArrayList<Map.Entry<String, Integer>>(map.entrySet());
Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {

@Override
public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
if (o1.getValue() == o2.getValue()) {
return o1.getKey().compareTo(o2.getKey());
}
return o2.getValue() - o1.getValue();
}

});
System.out.println(map.size());
int num = 0;
for (Map.Entry<String, Integer> m : list) {
if (num == 10)
break;
System.out.println(m.getKey() + "=" + m.getValue());
num++;
}

sc.close();

}

}

